package com.alien.admin.config;

import com.alien.admin.utils.AdminConstant;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 文件配置
 *
 * @author: alien.guo
 * @date: 2020/12/24
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "file")
public class FileProperties {

    /** 文件大小限制 */
    private Long maxSize;

    /** 头像大小限制 */
    private Long avatarMaxSize;

    private Path mac;

    private Path linux;

    private Path windows;

    public Path getPath(){
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith(AdminConstant.WIN)) {
            return windows;
        } else if (os.toLowerCase().startsWith(AdminConstant.MAC)) {
            return mac;
        }
        return linux;
    }

    @Data
    public static class Path {

        private String path;

        private String avatar;
    }
}
